package com.yunhe.authority.service.base.impl;

import com.yunhe.authority.domain.base.Notification;
import com.yunhe.authority.repository.base.NotificationRepository;
import com.yunhe.authority.service.base.NotificationService;
import com.yunhe.common.model.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

/**
 * @author zhengbo
 * @date 2021/5/20 15:51
 */
@Service
public class NotificationServiceImpl implements NotificationService {

    @Autowired
    private NotificationRepository notificationRepository;

    @Override
    public Notification creatNotification(Notification notification) {
        return notificationRepository.save(notification);
    }

    @Override
    public Page<Notification> searchNotificationList(PageParam pageParam) {
        Pageable pageable = PageRequest.of(pageParam.getPage() - 1, pageParam.getSize());
        return notificationRepository.findAll(pageable);
    }
}
